package jmine.tec.services.api.execution;

import static jmine.tec.services.api.execution.ExecutorTransactionPolicy.WHEN_NEEDED;
import static jmine.tec.services.api.execution.ExecutorValidationPolicy.BEFORE_ANY_EXECUTION;

/**
 * Parâmetros para execução de serviços
 * 
 * @author lundberg
 */
public class ExecutorParams {

    private final ExecutorTransactionPolicy transactionPolicy;

    private final ExecutorValidationPolicy validationPolicy;

    private final boolean continueAfterFailure;

    /**
     * Construtor
     * 
     * @param transactionPolicy transactionPolicy
     * @param validationPolicy validationPolicy
     * @param continueAfterFailure continueAfterFailure
     */
    public ExecutorParams(ExecutorTransactionPolicy transactionPolicy, ExecutorValidationPolicy validationPolicy,
            boolean continueAfterFailure) {
        this.transactionPolicy = transactionPolicy;
        this.validationPolicy = validationPolicy;
        this.continueAfterFailure = continueAfterFailure;
    }

    /**
     * Construtor que define os parâmetros default para execução de serviços: política de transações WHEN_NEEDED, validações
     * BEFORE_ANY_EXECUTION e pára quando um bloco falha.
     */
    public ExecutorParams() {
        this(WHEN_NEEDED, BEFORE_ANY_EXECUTION, false);
    }

    /**
     * @return the transactionPolicy
     */
    public ExecutorTransactionPolicy getTransactionPolicy() {
        return this.transactionPolicy;
    }

    /**
     * @return the validationPolicy
     */
    public ExecutorValidationPolicy getValidationPolicy() {
        return this.validationPolicy;
    }

    /**
     * @return the continueAfterFailure
     */
    public boolean isContinueAfterFailure() {
        return this.continueAfterFailure;
    }
}
